package com.luanye.enjoy.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.luanye.enjoy.constants.MQConst.*;

@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue articleQueue() {
        return new Queue(MAXWELL_QUEUE, true);
    }

    @Bean
    public FanoutExchange maxWellExchange() {
        return new FanoutExchange(MAXWELL_EXCHANGE, true, false);
    }

    @Bean
    public Binding bindingArticleDirect() {
        return BindingBuilder.bind(articleQueue()).to(maxWellExchange());
    }

    @Bean
    public Queue smsQueue(){
        return new Queue(SMS_QUEUE, true);
    }

    @Bean
    public FanoutExchange smsExchange(){
        return new FanoutExchange(SMS_EXCHANGE, true, false);
    }

    @Bean
    public Binding bindingSms() {
        return BindingBuilder.bind(smsQueue()).to(smsExchange());
    }
}
